﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace 列车时刻查询系统
{
    public partial class guanliyuan : Form
    {
        SqlConnection conn=null;
        public guanliyuan()
        {
            InitializeComponent();
        }

        private void guanliyuan_Load(object sender, EventArgs e)
        {
            // TODO: 这行代码将数据加载到表“traintimeDataSet.users”中。您可以根据需要移动或删除它。
            this.usersTableAdapter.Fill(this.traintimeDataSet.users);
            string sql = "server=.;database=traintime;integrated security=true;";
            conn = new SqlConnection(sql);
            conn.Open();
            if (conn.State == ConnectionState.Open)
                this.Text = "用户管理(已连接)";

        }

        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.usersTableAdapter.Update(this.traintimeDataSet.users);
            MessageBox.Show("修改成功！");
        }

        private void button3_Click(object sender, EventArgs e)
        {
            this.usersTableAdapter.Fill(this.traintimeDataSet.users);
        }

        private void button4_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "")
            {
                MessageBox.Show("搜索内容不能为空！");
            }
                this.usersBindingSource.Filter=  "username='" + textBox1.Text + "'";
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
